package com.example.util.mq.disruptor.service;

import com.example.util.handler.SpringContextHandler;
import com.example.util.model.GwBusiProtocol;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author wk
 * @date 2022/05/09
 * @description
 */
@Component
public class CspServiceFactory {


    public static <T> T getOpCspService(GwBusiProtocol requestType, Class<T> serviceClass) {
        return getOpCspService(requestType);
    }

    private static <T> T getOpCspService(GwBusiProtocol requestType) {

        Assert.notNull(requestType, "业务类型不能为空");

        String beanName = requestType.getClassName();

        Assert.notNull(beanName, "无法匹配合适的实现类");

        return (T) SpringContextHandler.getBean(beanName);
    }

}
